package com.dingding.order.core.march.sql;

/** 
 * @ClassName: LatelyOrderDaoSql 
 * @Description: 进行中订单通用SQL
 * @author chenwei
 * @date 2016年6月3日 上午11:42:13 
 * @version 叮叮搭车V2.2 
*/
public class MarchOrderDaoSql {

	/**
	 * 查看用户最近订单SQL
	 * 
	 * @author yhq
	 * 
	 */
	public static final String GET_LAST_USER_ORDER = "SELECT ud.loginId,ud.nickName,ud.userAvatar,ud.tellphone,u.setOutTime,u.totalMoney,u.redBag,u.message,u.number,u.startAddress,u.startLongitude,u.startLatitude,u.endAddress,u.endLongitude,u.endLatitude,u.orderStatus,u.oid,u.orderType,u.placeOrderUserId,u.grabOrderUserId,CASE WHEN u.orderStatus = 2 THEN u.grabOrderTime ELSE u.createTime END orderValidateTime,ud.userTabloidAvatar,u.distance,ud.sex,u.isLongDistance,u.ucid,u.couponMoney,ud.userLevel,u.setOutCondition,u.isCarShare,u.parOrderId,vi.vehicleType,vi.vehicleModel,vi.vehicleColor,vi.vehicleImage,vi.lisencePlate FROM userordert u INNER JOIN userdetail ud ON ud.loginId = CASE WHEN u.placeOrderUserId = ? AND u.grabOrderUserId IS NOT NULL THEN u.grabOrderUserId ELSE u.placeOrderUserId END INNER JOIN vehicleinfo vi ON vi.loginId = ud.loginId WHERE (u.placeOrderUserId = ? OR u.grabOrderUserId = ?) AND ((u.orderStatus = 1 AND u.isChildren = 1) OR (u.orderStatus IN (1,2,3) AND u.isChildren = 2)) ORDER BY u.createTime;";

	
	/**
	 * 查看最近的出租车订单SQL
	 * @author zhouxuan
	 * @since V2.3.0
	 */
	public static final String GET_LAST_USER_TAXI_ORDER="SELECT utt.distance,utt.endAddress,utt.endLatitude,utt.endLongitude,utt.grabOrderUserId,vi.lisencePlate,utt.message,ud.nickName,utt.number,utt.taxiOrdertId,utt.orderStatus,utt.placeOrderUserId,utt.setOutTime,ud.sex,utt.startAddress,utt.startLatitude,utt.startLongitude, ud.telPhone,utt.totalMoney,ud.userAvatar,ud.userLevel,ud.userTabloidAvatar,vi.vehicleColor,vi.vehicleModel,vi.vehicleType FROM usertaxiordert utt INNER JOIN specialuserinfo ud ON ud.userId = utt.grabOrderUserId  AND utt.orderStatus <> 1 LEFT JOIN specialuservehicleinfo vi ON vi.userId = utt.grabOrderUserId AND utt.orderStatus <> 1 AND utt.grabOrderUserId IS NOT NULL WHERE utt.orderStatus IN(2,3) AND (utt.placeOrderUserId = ? OR utt.grabOrderUserId = ?) ORDER BY utt.createTime";

	/**
	 * 获取出租车进行中订单(待抢单)
	 */
	public static final String GET_TO_BE_PAID_TAXI_ORDER = "SELECT utt.distance,utt.endAddress,utt.endLatitude,utt.endLongitude,utt.grabOrderUserId,vi.lisencePlate,utt.message,ud.nickName,utt.number,utt.taxiOrdertId,utt.orderStatus,utt.placeOrderUserId,utt.setOutTime,ud.sex,utt.startAddress,utt.startLatitude,utt.startLongitude, ud.tellphone,utt.totalMoney,ud.userAvatar,ud.userLevel,ud.userTabloidAvatar,vi.vehicleColor,vi.vehicleModel,vi.vehicleType FROM usertaxiordert utt INNER JOIN userdetail ud ON ud.loginId = utt.placeOrderUserId LEFT JOIN specialuservehicleinfo vi ON vi.userId = utt.grabOrderUserId AND utt.orderStatus <> 1 AND utt.grabOrderUserId IS NOT NULL WHERE utt.orderStatus = 1 AND (utt.placeOrderUserId = ? OR utt.grabOrderUserId = ?) ORDER BY utt.createTime";
	
}
